﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace COUP.Core
{
    public class ItemStore
    {
        private Dictionary<int, Item> Items;
        private int Capacity;

        public ItemStore(int Size = 20)
        {
            Items = new Dictionary<int, Item>(Size);
            Capacity = Size;
        }

        public void Insert(Item _item)
        {
            if (Items.Count < Capacity)
                Items.Add(_item.UniqueID, _item);
        }

        public void Equip(Item _item, ItemStore Inventory)
        {
            if (Items[_item.Position].UniqueID == 0)
                Items.Add(_item.Position, _item);
            else
            {
                Unequip(_item.Position, Inventory);
                Items.Add(_item.Position, _item);
            }

            Inventory.Remove(_item.UniqueID);
        }

        public void Unequip(int Position, ItemStore Inventory)
        {            
            Item Equipment = Items[Position];
            Items.Remove(Position);
            Inventory.Insert(Equipment);
        }

        public void Remove(int ItemUID)
        {
            Items.Remove(ItemUID);
        }

        public Item GetItem(int KeyValue)
        {
            if (Items.ContainsKey(KeyValue))
                return Items[KeyValue];
            else
                return new Item();
        }
    }
}
